Introduction

Stream ciphers avail themselves of pseudorandom generators (PRGs) in order to allow for messages with a length arbitrarily larger than the key's. Under the hood, they are nothing more than the One-Time Pad paired with a pseudorandom generator.

Definition: Stream Cipher

A stream cipher is a cipher equipped with a pseudorandom generator which takes a key of length , a message of length and produces a ciphertext of length and is defined as follows:

The seed is derived from the key .

Definition Breakdown

To encrypt a message a stream cipher first derives a seed from the key . It then passes this seed to the generator to generate a string of pseudorandom bits, called a keystream, which is as at least as long as the message . The first bits of the keystream are then XOR-ed with the message to obtain the ciphertext and the rest of the keystream is simply discarded.

The decryption algorithm once again uses the key to derive the seed . The seed is then passed on to the generator in order to produce the same keystream used during the encryption. The first bits of the keystream are then XOR-ed with the ciphertext to retrieve the message. As before, if the keystream is longer than the message, any additional bits are simply ignored.

Note that the message and the resulting ciphertext are of equal length.

Seed Derivation

In order to generate the keystream, the pseudorandom generator needs a seed. In the most basic cases, the key is used as the seed. However, usually the seed is created by appending to the key another binary string called the initialisation vector (IV).

The IV must be a random string and the same IV should never be used with the same key. Moreover, the IV must be known for decryption in order to derive the same seed from the key. Therefore, decryption requires both the key and the IV to function.

The purpose of the initialisation vector is to allow for key reuse. So long as the same key is used with different IVs, it poses no threat to the security of the cipher under a ciphertext-only attack.

Security

A stream cipher is semantically-secure so long as it uses a secure PRG.

Proof: Semantic Security of Stream Ciphers

We are given a stream cipher which uses a secure pseudorandom generator under the hood and we need to prove that the cipher is semantically secure.

Essentially, it all boils down to the security of the one-time pad. If instead of using a generator the message was XOR-ed with a truly random string , then we get a one-time pad which is perfectly secret (and by extension also semantically secure), i.e.

Suppose, towards contradiction, that there was an adversary which when given two messages and a ciphertext of either or can guess with probability significantly better than whether was obtained from or , i.e.

for some non-negligible . This can be rewritten as

However, this means that the adversary can distinguish between a string XOR-ed with the output of the generator and a string XOR-ed with a truly random string which contradicts the security of .